home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex39.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  551 b   |  26 lines

  1. Program ex39;
  2.  
  3. { Program to demonstrate the TUnsortedStrCollection.Insert method }
  4.  
  5. Uses Objects,Strings;
  6.  
  7. Var C : PUnsortedStrCollection;
  8.     S : String;
  9.     I : longint;
  10.     P : Pchar;
  11.     
  12. begin
  13.   Randomize;
  14.   C:=New(PUnsortedStrCollection,Init(120,10));
  15.   Writeln ('Inserting 100 records at random places.');
  16.   For I:=1 to 100 do
  17.     begin
  18.     Str(Random(100),S);
  19.     S:='String with value '+S;
  20.     P:=StrAlloc(Length(S)+1);
  21.     C^.Insert(StrPCopy(P,S));
  22.     end;
  23.   For I:=0 to 99 do
  24.     Writeln (I:2,': ',PChar(C^.At(i)));
  25.   Dispose(C,Done);
  26. end.